package com.zhkjnet.zhyy.job;

import com.zhkjnet.zhyy.entity.Asset;
import com.zhkjnet.zhyy.service.AssetService;
import com.zhkjnet.zhyy.util.SMSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class MinMoneyJob {

    @Autowired
    private AssetService assetService;

    /**
     * 每天12点提醒
     */
    @Scheduled(cron = "0 0 12 * * ?")
    public void execute() {
        List<Asset> assets = assetService.findAllRemind();
        for (Asset asset : assets) {
            SMSUtil.sendRemind(asset.getUser().getPhone());
        }
    }

}
